<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 数组解构赋值
        // const arr=["文字","治愈","势力"]
        // let [青春,电影,权威] = arr
        // console.log(青春);

        // 获取数组的某一项
        // const arr1=["33","治愈","势力"]
        // const [语言,,] = arr1
        // console.log(语言);

        // 获取数组的最后一项
        // const arr1=["33","治愈","势力"]
        // const [...rest] = arr1
        // console.log(rest);

        // 数组赋值（少，多，数组赋值时可以给多出来的属性同时赋值
        // const arr1=["33","治愈","势力"]
        // const [rest,must,go,more=123] = arr1
        // console.log(more);


        // 字符串解构赋值（之前办法:将字符串分割成数组 再根据数组下标获取数组的某一项 
        // const str="人之初 性本善 习相近 性相远"
        // const obj1=str.split(" ")
        // console.log(obj1[1])

        // 字符串解构赋值 (将字符串分割成数组，直接用数组的解构赋值)  
        // const str="人之初 性本善 习相近 性相远"
        // const [,a,,b]=str.split(" ")
        // console.log(b)

        // 对象解构调用属性值
        // const obj = {name:"zz",age:19,weight:45}
        // const{age}=obj
        // console.log(age)


        // 对象解构赋值
        const obj1 = {name:"zz",age:19,weight:45}
        const name1 = "xx"
        // const{name}=obj
        console.log(name1)

           
        // 对象解构修改（名字）赋值
        const obj = {name:"zz",age:19,weight:45}
        const name = "xx"
        const{name:newName}=obj
        console.log(newName)



    </script>
</body>
</html>